package com.i8office.android.zhihuixinwu.module.presenter;

import com.cyan.tools.callback.SimpleCallback;
import com.i8office.android.zhihuixinwu.bean.NewsAttachment;
import com.i8office.android.zhihuixinwu.module.contract.AttachmentContract;
import com.i8office.android.zhihuixinwu.module.model.AttachmentModel;

import java.util.List;

public class AttachmentPresenter extends BasePresenterImpl<AttachmentContract.View> implements AttachmentContract.Presenter {
    private AttachmentContract.Model model;
    public AttachmentPresenter(AttachmentContract.View view) {
        super(view);
        model = new AttachmentModel();
    }

    @Override
    public void getAttachments(String id) {
        addDisposable(model.getAttachments(new SimpleCallback<List<NewsAttachment>>(mView){
            @Override
            public void requestSuccess(List<NewsAttachment> data) {
                super.requestSuccess(data);
                mView.showAttachments(data);
            }

            @Override
            public void requestError(String msg) {
                super.requestError(msg);
                mView.toast(msg);
            }
        },id));
    }

}
